package demo;

import java.util.Scanner;

public class MovieOperator
{
    private  Movie[] movies;

    public MovieOperator(Movie movies[])
    {
        this.movies = movies;
    }

    public void printAllMovies()
    {
        int i = 0;
        for(i = 0;i < movies.length;i++)
        {
            Movie m = movies[i];
            System.out.println(m.getId()+"\t"+m.getName()+"\t"+"\t"+m.getScore()+"\t"+m.getActor());

        }
    }
    //根据id查询电影
    public void searchMovie()
    {
        System.out.println("请输入要查询的id");
        Scanner sc = new Scanner(System.in);
        int id = sc.nextInt();

        for(int i = 0;i<movies.length;i++)
        {
            Movie m = movies[i];
            if(movies[i].getId() == id)
            {
                System.out.println(m.getId()+"\t"+m.getName()+"\t"+m.getActor()+"\t"+m.getScore());
                return;
            }

        }
        System.out.println("没有此id");
    }
}
